class Solution {
public:
    int addMinimum(string word) {
        int cnt = 0;
        int n = word.size();
        char t = 'c';
        for (auto x : word) {
            if (x == 'a') {
                if (t == 'a')cnt += 2;
                else if (t == 'b')cnt++;
            }
            else if (x == 'b') {
                if (t == 'b')cnt += 2;
                else if (t == 'c')cnt++;
            }
            else {
                if (t == 'c')cnt += 2;
                else if (t == 'a')cnt++;
            }
            t = x;
        }
        if (word[n - 1] == 'b')cnt++;
        else if (word[n - 1] == 'a')cnt += 2;
        return cnt;
    }
};